package com.company.fusai;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 加数补全类
 *
 * @author jianf
 * @date 2021年09月12 21:12
 */
public class NumberPatch {

    public int[] doPatch(int n,int[] nums){
        int[] reslut = new int[]{};
        int rang =1,i=0;
        while ( rang <= n){
           if(i < nums.length && nums[i] <= rang ){
                rang += nums[i++];
           }else {
               reslut = Arrays.copyOf(reslut,reslut.length+1);
               reslut[reslut.length -1] = rang;
               rang +=rang;
           }
        }
        return  reslut;
    }

    public static void main(String[] args) {
        int n = 79;
        int[] nums = {1,6,10};
        NumberPatch numberPatch = new NumberPatch();
        System.out.println("\n应补充的数字为：" + Arrays.toString(numberPatch.doPatch(n, nums)));
    }
}
